﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;

namespace com.intellitack.layar.library
{
    //POIAction Class
    public class POIAction : AbstractLayarObject
    {
        #region Protected Properties
        protected string _uri;
        protected string _label;
        #endregion

        public POIAction(string inUri, string inLabel) 
        {
            _uri = inUri;
            _label = inLabel;
        }

        #region Public Properties
        /// <summary>
        /// The specific client application for the URI will be launched.  
        /// Except for the http:// URIs which are displayed in a web view direclty in the Layar app.
        /// The possible URIs are:
        ///   -"tel:"
        ///   -"sms:"
        ///   -"mailto:"
        ///   -"http://"
        ///   -"https://"
        /// 
        /// Note:  All forward slashed must be replaced with \/.  This screws up the Serializer, so I'll need 
        /// to write my own for this class.
        /// </summary>
        public string uri
        {
            get
            {
                //Replace all forward slashes / with \/
                return _uri;
            }
            set
            {
                _uri = value;
            }
        }

        /// <summary>
        /// If specified, the text will be displayed in teh button corresponding to the action.  Otherwise the app will show a default text deping on the URI scheme used.
        /// </summary>
        public string label
        {
            get
            {
                return _label;
            }
            set
            {
                _label = value; 
            }
        }
        #endregion

        #region Public Methods
        public override string Serialize() 
        {
            StringBuilder sb = new StringBuilder();

            //Add class start
            sb.Append("{");
            sb.Append(SerializeProperty("uri", LayarEncodeURL(uri)));
            sb.Append(",");
            sb.Append(SerializeProperty("label", label));
            sb.Append("}");

            return sb.ToString();
        }
        #endregion

    }


    
 
}
